package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"

	cent "gitee.com/shuokeyun/common/ent"
)

type OrderOriginal struct {
	ent.Schema
}

func (OrderOriginal) Mixin() []ent.Mixin {
	return []ent.Mixin{
		cent.OrmMixin{},
	}
}

func (OrderOriginal) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{
			Table: "sk_order_original",
		},
	}
}

func (OrderOriginal) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("order_id").Comment("订单id"),
		field.String("item_code").Immutable().Comment("套餐编号"),
		field.String("item_name").Immutable().Comment("套餐名称"),
		field.String("item_code_detail").Immutable().Comment("子项编码"),
		field.Int32("price").Immutable().Comment("价格(分)"),
		field.Int32("market_price").Immutable().Comment("市场价(分)"),
	}
}

func (OrderOriginal) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("order", Order.Type).Ref("originals").Unique().Required().Field("order_id"),
	}
}
